<template>
  <div class="cecil">
    <div class="cecil-top">
      <span>嗨购秒杀</span>
      <span class="cecil-top-text">8点场</span>
      <van-count-down :time="time">
        <template #default="timeData">
          <span class="block">{{ timeData.hours }}</span>
          <span class="colon">:</span>
          <span class="block">{{ timeData.minutes }}</span>
          <span class="colon">:</span>
          <span class="block">{{ timeData.seconds }}</span>
        </template>
      </van-count-down>
    </div>
    <ul>
      <li
        v-for="item in cecilList"
        :key="item.proid"
        @click="onGoDetail(item.proid)"
      >
        <img :src="item.img1" alt="" class="cecil-img" />
        <p class="cecil-text">￥:{{ item.originprice }}</p>
      </li>
    </ul>
  </div>
</template>

<script>
import { getGoodsCecilList } from "@/api/home";
export default {
  name: "Cecil",
  data() {
    return {
      time: 2 * 60 * 60 * 1000,
      cecilList: [],
    };
  },
  methods: {
    async getCecilList() {
      let res = await getGoodsCecilList({ count: 1, limitNum: 20 });
      if (res.data.code === "200") {
        this.cecilList = res.data.data;
        // console.log(res);
      }
    },

    onGoDetail(id) {
      this.$router.push('/Detail/'+id);
    },
  },
  created() {
    this.getCecilList();
    // this.onGoDetail()
  },
};
</script>

<style scoped>
.cecil {
  width: 100%;
  height: 1.45rem;
  display: flex;
  border: 1px solid #555;
  border-radius: 0.08rem;
  flex-direction: column;
  background-color: #eff;
}
.cecil-top {
  width: 100%;
  height: 15%;
  display: flex;
  /* justify-content: space-around; */
}
.cecil-top-text {
  /* display: inline-block; */
  margin-left: 0.4rem;
}
.cecil-img {
  /* width: 100%; */
  height: 100%;
}
.cecil-text {
  color: red;
  font-size: 0.14rem;
  text-align: center;
}
.van-count-down {
  margin-left: 0.4rem;
}
.cecil > ul {
  widows: 100%;
  height: 90%;
  /* background-color: coral; */
  flex: 1;
  display: flex;
  overflow-x: auto;
  justify-content: space-between;
}
.cecil > ul > li {
  widows: 1rem;
  height: 1rem;
  /* background-color: yellowgreen; */
  padding: 0.05rem;
}

.colon {
  display: inline-block;
  margin: 0 4px;
  color: #ee0a24;
}
.block {
  display: inline-block;
  width: 22px;
  color: #fff;
  font-size: 12px;
  text-align: center;
  background-color: #ee0a24;
}
</style>
